package com.ruoyi.api.kehu.item;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.JiajiaItem;
import com.ruoyi.system.domain.JiajiaItemBigType;
import com.ruoyi.system.domain.JiajiaItemType;
import com.ruoyi.system.service.IJiajiaItemBigTypeService;
import com.ruoyi.system.service.IJiajiaItemService;
import com.ruoyi.system.service.IJiajiaItemTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/api/kehu/item")
@Api(tags = "用户项目相关接口")
public class ApiItemController {

    @Autowired
    private IJiajiaItemService ItemService;
    @Autowired
    private IJiajiaItemTypeService jiajiaItemTypeService;

    @Autowired
    private IJiajiaItemBigTypeService jiajiaItemBigTypeService;

    @ApiOperation("项目详情")
    @PostMapping("/itemDetail")
    public AjaxResult itemDetail(@RequestParam @ApiParam(value = "项目id") Long id){
        JiajiaItem item= ItemService.selectJiajiaItemById(id);
        return AjaxResult.success(item);
    }

    @ApiOperation("项目类型列表")
    @GetMapping("/type/list")
    public AjaxResult itemTypeList(JiajiaItemType jiajiaItemType){
        List<JiajiaItemType> itemTypeList = jiajiaItemTypeService.apiSelectJiajiaItemTypeList(jiajiaItemType);
        return AjaxResult.success(itemTypeList);
    }

    @ApiOperation("大类列表")
    @GetMapping("/bigType/list")
    public AjaxResult bigTypeList(JiajiaItemBigType jiajiaItemBigType){
        List<JiajiaItemBigType> itemTypeList = jiajiaItemBigTypeService.selectJiajiaItemBigTypeList(jiajiaItemBigType);
        return AjaxResult.success(itemTypeList);
    }
}
